package data 
{
	import flash.geom.Point;
	import flash.utils.Dictionary;
	/**
	 * Data for the city
	 */
	public class GCCityData 
	{
		/**
		 * City Id
		 */
		public static const CITY_PICAROON:uint = 	0;
		public static const CITY_TAFFEREL:uint = 	1;
		public static const CITY_XEBEK:uint = 		2;
		public static const CITY_ALLEGIO:uint = 	3;
		public static const CITY_ONDA:uint = 		4;
		public static const CITY_MARINO:uint = 		5;
		public static const CITY_SHANBAN:uint = 	6;
		public static const CITY_CHUAN:uint = 		7;
		public static const CITY_HAI_JING:uint = 	8;
		public static const CITY_CHUMBUCKET:uint = 	9;
		public static const CITY_DUNDERFUNK:uint = 	10;
		public static const CITY_HORNSWAGGLE:uint = 11;
		
		public static const NUM_CITIES:uint = 		12;
		
		// Special location indicating ship (used for database)
		public static const CITY_SHIP:uint = 1000;
		
		public static var _information:Dictionary;
		
		public static function initialize():void
		{
			_information = new Dictionary();
			var gatherableResources:Vector.<uint>;
			var pathsAvailable:Vector.<uint>; // TODO: Fill this in before adding to each
			var name:String;
			var pathsImage:String; // TODO: Fill this in before adding to each
			var coord:Point;
			var shipCoord:Point;
			var infoCoord:Point;	// Coordinate to put info box, where its not hidden (relative to city image)
			
			name = "Picaroon";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_FOOD);
			gatherableResources.push(GCItemData.ITEM_LUMBER);
			coord = new Point(610, 115);
			shipCoord = new Point(595, 64);
			infoCoord = new Point(-10, 50);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_PICAROON_TAFFEREL, GCPathData.PATH_PICAROON_ALLEGIO, GCPathData.PATH_PICAROON_XEBEK]);
			_information[CITY_PICAROON] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Tafferel";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_FOOD);
			gatherableResources.push(GCItemData.ITEM_COTTON);
			coord = new Point(530, 50);
			shipCoord = new Point(522, 85);
			infoCoord = new Point(-150, 20);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_PICAROON_TAFFEREL, GCPathData.PATH_TAFFEREL_ONDA, GCPathData.PATH_TAFFEREL_XEBEK]);
			_information[CITY_TAFFEREL] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Xebek";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_LUMBER);
			gatherableResources.push(GCItemData.ITEM_COPPER);
			coord = new Point(470, 220);
			shipCoord = new Point(507, 245);
			infoCoord = new Point(0, 50);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_ALLEGIO_XEBEK, GCPathData.PATH_PICAROON_XEBEK, GCPathData.PATH_TAFFEREL_XEBEK,
					GCPathData.PATH_XEBEK_HORNSWAGGLE, GCPathData.PATH_XEBEK_ONDA]);
			_information[CITY_XEBEK] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Allegio";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_IRON);
			gatherableResources.push(GCItemData.ITEM_COAL);
			gatherableResources.push(GCItemData.ITEM_SALT);
			coord = new Point(640, 400);
			shipCoord = new Point(646, 329);
			infoCoord = new Point(-50, -250);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_ALLEGIO_MARINO, GCPathData.PATH_ALLEGIO_XEBEK, GCPathData.PATH_PICAROON_ALLEGIO]);
			_information[CITY_ALLEGIO] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Onda";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_FOOD);
			gatherableResources.push(GCItemData.ITEM_COPPER);
			coord = new Point(430, 160);
			shipCoord = new Point(447, 99);
			infoCoord = new Point(-150, 0);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_DUNDERFUNK_ONDA, GCPathData.PATH_ONDA_SHANBAN, GCPathData.PATH_TAFFEREL_ONDA,
					GCPathData.PATH_XEBEK_ONDA]);
			_information[CITY_ONDA] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Marino";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_WOOL);
			gatherableResources.push(GCItemData.ITEM_IRON);
			gatherableResources.push(GCItemData.ITEM_LUMBER);
			coord = new Point(560, 450);
			shipCoord = new Point(472, 441);
			infoCoord = new Point(-100, -250);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_ALLEGIO_MARINO, GCPathData.PATH_MARINO_CHUAN, GCPathData.PATH_MARINO_HORNSWAGGLE]);
			_information[CITY_MARINO] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Chuan";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_FOOD);
			gatherableResources.push(GCItemData.ITEM_LUMBER);
			gatherableResources.push(GCItemData.ITEM_SPICES);
			coord = new Point(245, 425);
			shipCoord = new Point(305, 440);
			infoCoord = new Point(-150, -200);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_CHUAN_DUNDERFUNK, GCPathData.PATH_CHUAN_HAI_JING,
					GCPathData.PATH_CHUAN_HORNSWAGGLE, GCPathData.PATH_MARINO_CHUAN]);
			_information[CITY_CHUAN] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Hai Jing";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_COAL);
			gatherableResources.push(GCItemData.ITEM_OIL);
			coord = new Point(55, 305);
			shipCoord = new Point(36, 259);
			infoCoord = new Point(100, -150);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_CHUMBUCKET_HAI_JING, GCPathData.PATH_HAI_JING_DUNDERFUNK,
					GCPathData.PATH_CHUAN_HAI_JING]);
			_information[CITY_HAI_JING] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Shanban";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_SALT);
			gatherableResources.push(GCItemData.ITEM_SPICES);
			gatherableResources.push(GCItemData.ITEM_FOOD);
			coord = new Point(112, 65);
			shipCoord = new Point(180, 83);
			infoCoord = new Point(0, 50);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_ONDA_SHANBAN, GCPathData.PATH_SHANBAN_CHUMBUCKET, GCPathData.PATH_SHANBAN_DUNDERFUNK]);
			_information[CITY_SHANBAN] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Chumbucket";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_IRON);
			gatherableResources.push(GCItemData.ITEM_WOOL);
			gatherableResources.push(GCItemData.ITEM_LUMBER);
			coord = new Point(20, 125);
			shipCoord = new Point(81, 146);
			infoCoord = new Point(0, 50);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_CHUMBUCKET_HAI_JING, GCPathData.PATH_SHANBAN_CHUMBUCKET]);
			_information[CITY_CHUMBUCKET] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Dunderfunk";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_SILVER);
			gatherableResources.push(GCItemData.ITEM_OIL);
			coord = new Point(340, 200);
			shipCoord = new Point(276, 212);
			infoCoord = new Point(0, 50);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_CHUAN_DUNDERFUNK, GCPathData.PATH_DUNDERFUNK_ONDA,
					GCPathData.PATH_HAI_JING_DUNDERFUNK, GCPathData.PATH_HORNSWAGGLE_DUNDERFUNK, GCPathData.PATH_SHANBAN_DUNDERFUNK]);
			_information[CITY_DUNDERFUNK] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
			
			name = "Hornswaggle";
			gatherableResources = new Vector.<uint>();
			gatherableResources.push(GCItemData.ITEM_SPICES);
			gatherableResources.push(GCItemData.ITEM_COAL);
			gatherableResources.push(GCItemData.ITEM_SILK);
			coord = new Point(405, 265);
			shipCoord = new Point(407, 325);
			infoCoord = new Point(-150, -100);
			pathsImage = name + " Routes.png";
			pathsAvailable = Vector.<uint>([GCPathData.PATH_CHUAN_HORNSWAGGLE, GCPathData.PATH_HORNSWAGGLE_DUNDERFUNK,
					GCPathData.PATH_XEBEK_HORNSWAGGLE, GCPathData.PATH_MARINO_HORNSWAGGLE]);
			_information[CITY_HORNSWAGGLE] = new GCCityDataStruct(name, gatherableResources, pathsImage, pathsAvailable, coord, shipCoord, infoCoord);
		}
		
		public static function getPathForCities(cityA:uint, cityB:uint):uint
		{
			for each (var pathA:uint in _information[cityA]._pathsAvailable) {
				for each (var pathB:uint in _information[cityB]._pathsAvailable) {
					if (pathA == pathB) {
						return pathA;
					}
				}
			}
			return 404; // Something went wrong...
		}
		
		public static function getNameFromId(id:uint):String
		{
			return (_information[id] as GCCityDataStruct)._name;
		}
		
		public static function getResourcesFromId(id:uint):Vector.<uint>
		{
			return (_information[id] as GCCityDataStruct)._resourcesAvailable;
		}
		
		public static function getCoordinatesFromId(id:uint):Point
		{
			return (_information[id] as GCCityDataStruct)._coordinates;
		}
		
		public static function getShipCoordinatesFromId(id:uint):Point
		{
			return (_information[id] as GCCityDataStruct)._shipCoordinate;
		}
		
		public static function getInfoCoordinateFromId(id:uint):Point
		{
			return (_information[id] as GCCityDataStruct)._infoCoordinate;
		}
	}

}